<template>
  <view class="container">
    <form @submit.prevent="handleLogin">
      <view class="input-group">
        <input v-model="username" placeholder="请输入用户名" />
      </view>
      <view class="input-group">
        <input v-model="password" type="password" placeholder="请输入密码" />
      </view>
      <button type="submit" class="btn">登录</button>
    </form>
  </view>
</template>

<script>
export default {
  data() {
    return {
      username: '',
      password: ''
    };
  },
  methods: {
    handleLogin() {
      if (this.username && this.password) {
        // 模拟登录成功
        uni.setStorageSync('isLoggedIn', true);
        uni.navigateTo({
          url: '/pages/home/home'
        });
      } else {
        uni.showToast({
          title: '请输入用户名和密码',
          icon: 'none'
        });
      }
    }
  }
};
</script>

<style>
.container {
  padding: 20px;
}
.input-group {
  margin-bottom: 15px;
}
.btn {
  width: 100%;
  padding: 10px;
  background-color: #007aff;
  color: #fff;
  text-align: center;
  border-radius: 5px;
}
</style>